<jsp:useBean id="register" class="dasregistry.registryBean" scope="session"/>
<jsp:setProperty name="register" property="*"/>
<%@ page import="org.biojava.dasobert.dasregistry.*" %>

<% String title="register DAS 1 source";
   String header=title;
%>

<%@ include file="sangerheader.jsp" %>


<%@ include file="navigation.jsp" %>

<div id="main">
<p>

<h2> Step 3/3 store new DAS source in database</h2>

<%

 	boolean ignoreValidation = false;
	if ( isAdmin )  {	
		if ( register.getIgnoreValidation().equals("1")) 
			ignoreValidation = true;
	}


	int status = register.registerMe(ignoreValidation);
	if (status == 1) { 
	%>registering service ... o.k.!<br/>
	<% if(register.getAutoId()!=-1){
		int autoId=register.getAutoId();
		String identifier=String.valueOf(autoId);
		%>
	
	<a href="showdetails.jsp?auto_id=DS_<%=identifier%>">view details</a> of the registered DAS source and please note that it may not turn up in the search results for 24hrs.
	<% 
	} 
	}else if (status == 0) {
		out.println("registering service ... unknown error occured.");
	} else if (status == 2) {
		out.println("server already in database, not registering a second time.");
	} else if (status == 3) {
		String cstring = "";
		String[] caps = register.getCapabilities() ;
		for ( int c =0; c< caps.length ; c++ ) {
		   cstring +="&capabilities="+caps[c];
		}
		%>
		Server failed validation check! Please use the
		<% String testCode = "";
		   String[] testCodes = register.getTestCodes();
		   if ( testCodes.length > 0 ) 
		      testCode = testCodes[0];
		%>
		<a href="validateServer.jsp?dasurl=<%=register.getDasurl()%><%=cstring%>&testCode=<%=testCode%>"> validation page</a> 
		to get more info.
		<%
	} else if (status == 4) {
		out.println("database error -  could not add server to database");
	} else if (status == 5) {
		out.println("unknown capability -  could not add server to database");
	} else if (status == 6) {
		out.println("you did not specify a valid email address!");
	} else if (status == 7) {		
	  	out.println("You did not specify a valid url!");
	} else if (status == 8) {		
	  	out.println("You did not specify a valid description!");
	} else if (status == 9) {		
	  	out.println("Could not add service. There is a problem with the coordinate system!");
	} else if (status == 10) {		
	  	out.println("you did not specify a valid capability!");
	} else if (status == 11) {
		out.print("you did not specify an accession code / segment id. It is required to test if the server gives a valid response.");
	} else if (status == 12) {
		out.print("the specified nickname is already in use, or otherwise invalid"); 
	} else if ( status == 13) {
		out.print("the provided URL does not  match the DAS/1 specification."); 
	}
	else if ( status > 999) {
				
	%>
		server registered successfully!
		
		<p>the key to remove this server, or update the lease of this server is:</p>
		<p><b><%=status%></b></p>
		If you forget this key, you can request it again at the remove service or renew lease pages.
	<%
	} else {
		out.println(" error - received status " + status);
	}


%>

</div>


<%@ include file="sangerfooter.jsp" %>

